package com.laozhao.msas.view;

import java.awt.event.ActionEvent;
import java.beans.PropertyChangeListener;
import java.util.HashMap;
import java.util.Map;

import javax.swing.Action;
import javax.swing.JLabel;

public class LabelAction extends JLabel implements Action {
	private String name ;	
	private Map<String, Object> map = new HashMap<String, Object>();
	
	public LabelAction(String name){
		this.name = name;
		putValue(NAME, name);
	}
	@Override
	public void addPropertyChangeListener(PropertyChangeListener listener) {
		// TODO Auto-generated method stub

	}

	@Override
	public Object getValue(String key) {
		// TODO Auto-generated method stub
		return  map.get(key);
	}

	@Override
	public boolean isEnabled() {
		// TODO Auto-generated method stub
		return true;
	}

	@Override
	public void putValue(String key, Object value) {
		if (NAME.equals(key)) {
			setText(value.toString());
		}else if (SHORT_DESCRIPTION.equals(key)) {
			setToolTipText(value.toString());
		}
		
		map.put(key, value);		

	}

	@Override
	public void removePropertyChangeListener(PropertyChangeListener listener) {
		// TODO Auto-generated method stub

	}

	@Override
	public void setEnabled(boolean b) {
		// TODO Auto-generated method stub

	}

	@Override
	public void actionPerformed(ActionEvent e) {
		System.out.println("hello label action !"+name+e.getActionCommand());

	}

}
